home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / starwars.c < prev    next >
C/C++ Source or Header  |  2000-05-13  |  25KB  |  711 lines

  1. /***************************************************************************
  2. File: drivers\starwars.c
  3.  
  4. STARWARS HARDWARE FILE
  5.  
  6. This file is Copyright 1997, Steve Baines.
  7. Modified by Frank Palazzolo for sound support
  8.  
  9. Current e-mail contact address:  sjb@ohm.york.ac.uk
  10.  
  11. Release 2.0 (6 August 1997)
  12.  
  13. ***************************************************************************/
  14.  
  15. #include "driver.h"
  16. #include "vidhrdw/generic.h"
  17. #include "vidhrdw/vector.h"
  18. #include "vidhrdw/avgdvg.h"
  19. #include "machine/swmathbx.h"
  20. #include "machine/atari_vg.h"
  21.  
  22. /* formerly sndhrdw/starwars.h */
  23. READ_HANDLER( starwars_main_read_r );
  24. READ_HANDLER( starwars_main_ready_flag_r );
  25. WRITE_HANDLER( starwars_main_wr_w );
  26. WRITE_HANDLER( starwars_soundrst_w );
  27.  
  28. READ_HANDLER( starwars_sin_r );
  29. READ_HANDLER( starwars_m6532_r );
  30.  
  31. WRITE_HANDLER( starwars_sout_w );
  32. WRITE_HANDLER( starwars_m6532_w );
  33.  
  34. /* formerly machine/starwars.h */
  35. READ_HANDLER( starwars_input_bank_1_r );
  36. void starwars_wdclr(int, int);
  37.  
  38. READ_HANDLER( starwars_control_r );
  39. WRITE_HANDLER( starwars_control_w );
  40. int  starwars_interrupt (void);
  41.  
  42.  
  43. static unsigned char *nvram;
  44. static size_t nvram_size;
  45.  
  46. static void nvram_handler(void *file, int read_or_write)
  47. {
  48.     if (read_or_write)
  49.         osd_fwrite(file,nvram,nvram_size);
  50.     else
  51.     {
  52.         if (file)
  53.             osd_fread(file,nvram,nvram_size);
  54.         else
  55.             memset(nvram,0,nvram_size);
  56.     }
  57. }
  58.  
  59.  
  60.  
  61. WRITE_HANDLER( starwars_out_w )
  62. {
  63.     unsigned char *RAM = memory_region(REGION_CPU1);
  64.  
  65.     switch (offset)
  66.     {
  67.         case 0:        /* Coin counter 1 */
  68.             coin_counter_w (0, data);
  69.             break;
  70.         case 1:        /* Coin counter 2 */
  71.             coin_counter_w (1, data);
  72.             break;
  73.         case 2:        /* LED 3 */
  74.             osd_led_w (2, data >> 7);
  75.             break;
  76.         case 3:        /* LED 2 */
  77.             osd_led_w (1, data >> 7);
  78.             break;
  79.         case 4:
  80. //            logerror("bank_switch_w, %02x\n", data);
  81.             if (data & 0x80)
  82.             {
  83.                 cpu_setbank(1,&RAM[0x10000])
  84.                 cpu_setbank(2,&RAM[0x1c000])
  85.             }
  86.             else
  87.             {
  88.                 cpu_setbank(1,&RAM[0x06000]);
  89.                 cpu_setbank(2,&RAM[0x0a000]);
  90.             }
  91.             break;
  92.         case 5:
  93.             prngclr_w (offset, data);
  94.             break;
  95.         case 6:
  96.             osd_led_w (0, data >> 7);
  97.             break;    /* LED 1 */
  98.         case 7:
  99.             logerror("recall\n"); /* what's that? */
  100.             break;
  101.     }
  102. }
  103.  
  104. /* machine/slapstic.c */
  105. void slapstic_init (int chip);
  106. int slapstic_bank (void);
  107. int slapstic_tweak (offs_t offset);
  108.  
  109. static unsigned char *slapstic_base;    /* ASG - made static */
  110. static unsigned char *slapstic_area;
  111.  
  112. /* ASG - added this (including the function) */
  113. static int last_bank;
  114. static int esb_slapstic_tweak(offs_t offset)
  115. {
  116.     int bank = slapstic_tweak(offset);
  117.     if (bank != last_bank)
  118.     {
  119.         memcpy(slapstic_area, &slapstic_base[bank * 0x2000], 0x2000);
  120.         last_bank = bank;
  121.     }
  122.     return bank;
  123. }
  124.  
  125. static OPBASE_HANDLER( esb_setopbase )
  126. {
  127.     int prevpc = cpu_getpreviouspc ();
  128.     int bank;
  129.  
  130.     /*
  131.      *        This is a slightly ugly kludge for Indiana Jones & the Temple of Doom because it jumps
  132.      *        directly to code in the slapstic.  The general order of things is this:
  133.      *
  134.      *            jump to $3A, which turns off interrupts and jumps to $00 (the reset address)
  135.      *            look up the request in a table and jump there
  136.      *            (under some circumstances, tweak the special addresses)
  137.      *            return via an RTS at the real bankswitch address
  138.      *
  139.      *        To simulate this, we tweak the slapstic reset address on entry into slapstic code; then
  140.      *        we let the system tweak whatever other addresses it wishes.  On exit, we tweak the
  141.      *        address of the previous PC, which is the RTS instruction, thereby completing the
  142.      *        bankswitch sequence.
  143.      *
  144.      *        Fortunately for us, all 4 banks have exactly the same code at this point in their
  145.      *        ROM, so it doesn't matter which version we're actually executing.
  146.      */
  147.  
  148.     if ((address & 0xe000) == 0x8000)
  149.     {
  150. //        logerror("      new pc inside of slapstic region: %04x (prev = %04x)\n", pc, prevpc);
  151.         bank = esb_slapstic_tweak ((address) & 0x1fff);    /* ASG - switched to ESB version */
  152.         /* catching every branch during slapstic area */
  153.         catch_nextBranch();
  154.         return -1;
  155.     }
  156.     else if ((prevpc & 0xe000) == 0x8000)
  157.  {
  158. //  logerror("      old pc inside of slapstic region: %04x (new = %04x)\n", prevpc, pc);
  159. if (prevpc != 0x8080 && prevpc != 0x8090 && prevpc != 0x80a0 && prevpc !=0x80b0)
  160.   bank = esb_slapstic_tweak ((prevpc) & 0x1fff);    /* ASG - switched to ESB version */
  161.  }
  162.  
  163.     return address;
  164. }
  165.  
  166. void esb_init_machine (void)
  167. {
  168.     /* Set up the slapstic */
  169.     slapstic_init (101);
  170.     cpu_setOPbaseoverride (0,esb_setopbase);
  171.     /* ASG - added the following: */
  172.     memcpy(slapstic_area, &slapstic_base[slapstic_bank() * 0x2000], 0x2000);
  173.  
  174.     /* Reset all the banks */
  175.     starwars_out_w (4, 0);
  176.  
  177.     init_swmathbox ();
  178. }
  179.  
  180. /*************************************
  181.  *
  182.  *        Slapstic ROM read/write.
  183.  *
  184.  *************************************/
  185.  
  186. READ_HANDLER( esb_slapstic_r )
  187. {
  188.     int val;
  189.  
  190.     int bank = (esb_slapstic_tweak (offset) * 0x2000);    /* ASG - switched to ESB version */
  191.     val = slapstic_base[bank + (offset & 0x1fff)];
  192. //    logerror("slapstic_r, %04x: %02x\n", 0x8000 + offset, val);
  193.     return val;
  194. }
  195.  
  196.  
  197. WRITE_HANDLER( esb_slapstic_w )
  198. {
  199. //    logerror("esb slapstic tweak via write\n");
  200.     esb_slapstic_tweak (offset);    /* ASG - switched to ESB version */
  201. }
  202.  
  203. /* Star Wars READ memory map */
  204. static struct MemoryReadAddress readmem[] =
  205. {
  206.     { 0x0000, 0x2fff, MRA_RAM },   /* vector_ram */
  207.     { 0x3000, 0x3fff, MRA_ROM },        /* vector_rom */
  208.     { 0x4300, 0x431f, input_port_0_r }, /* Memory mapped input port 0 */
  209.     { 0x4320, 0x433f, starwars_input_bank_1_r }, /* Memory mapped input port 1 */
  210.     { 0x4340, 0x435f, input_port_2_r },    /* DIP switches bank 0 */
  211.     { 0x4360, 0x437f, input_port_3_r },    /* DIP switches bank 1 */
  212.     { 0x4380, 0x439f, starwars_control_r }, /* a-d control result */
  213.     { 0x4400, 0x4400, starwars_main_read_r },
  214.     { 0x4401, 0x4401, starwars_main_ready_flag_r },
  215.     { 0x4500, 0x45ff, MRA_RAM },        /* nov_ram */
  216.     { 0x4700, 0x4700, reh_r },
  217.     { 0x4701, 0x4701, rel_r },
  218.     { 0x4703, 0x4703, prng_r },            /* pseudo random number generator */
  219. /*    { 0x4800, 0x4fff, MRA_RAM }, */        /* cpu_ram */
  220. /*    { 0x5000, 0x5fff, MRA_RAM }, */        /* (math_ram_r) math_ram */
  221.     { 0x4800, 0x5fff, MRA_RAM },        /* CPU and Math RAM */
  222.     { 0x6000, 0x7fff, MRA_BANK1 },        /* banked ROM */
  223.     { 0x8000, 0xffff, MRA_ROM },        /* rest of main_rom */
  224.     { -1 }    /* end of table */
  225. };
  226.  
  227. /* Star Wars Sound READ memory map */
  228. static struct MemoryReadAddress readmem2[] =
  229. {
  230.     { 0x0800, 0x0fff, starwars_sin_r },        /* SIN Read */
  231.     { 0x1000, 0x107f, MRA_RAM },    /* 6532 RAM */
  232.     { 0x1080, 0x109f, starwars_m6532_r },
  233.     { 0x2000, 0x27ff, MRA_RAM },    /* program RAM */
  234.     { 0x4000, 0xbfff, MRA_ROM },    /* sound roms */
  235.     { 0xc000, 0xffff, MRA_ROM },    /* load last rom twice */
  236.                                     /* for proper int vec operation */
  237.     { -1 }  /* end of table */
  238. };
  239.  
  240. /* Star Wars WRITE memory map */
  241. static struct MemoryWriteAddress writemem[] =
  242. {
  243.     { 0x0000, 0x2fff, MWA_RAM, &vectorram, &vectorram_size }, /* vector_ram */
  244.     { 0x3000, 0x3fff, MWA_ROM },        /* vector_rom */
  245.     { 0x4400, 0x4400, starwars_main_wr_w },
  246.     { 0x4500, 0x45ff, MWA_RAM, &nvram, &nvram_size },        /* nov_ram */
  247.     { 0x4600, 0x461f, avgdvg_go_w },
  248.     { 0x4620, 0x463f, avgdvg_reset_w },
  249.     { 0x4640, 0x465f, MWA_NOP },        /* (wdclr) Watchdog clear */
  250.     { 0x4660, 0x467f, MWA_NOP },        /* irqclr: clear periodic interrupt */
  251.     { 0x4680, 0x4687, starwars_out_w },
  252.     { 0x46a0, 0x46bf, MWA_NOP },        /* nstore */
  253.     { 0x46c0, 0x46c2, starwars_control_w },    /* Selects which a-d control port (0-3) will be read */
  254.     { 0x46e0, 0x46e0, starwars_soundrst_w },
  255.     { 0x4700, 0x4707, swmathbx_w },
  256. /*    { 0x4800, 0x4fff, MWA_RAM }, */        /* cpu_ram */
  257. /*    { 0x5000, 0x5fff, MWA_RAM }, */        /* (math_ram_w) math_ram */
  258.     { 0x4800, 0x5fff, MWA_RAM },        /* CPU and Math RAM */
  259.     { 0x6000, 0xffff, MWA_ROM },        /* main_rom */
  260.     { -1 }    /* end of table */
  261. };
  262.  
  263. /* Star Wars sound WRITE memory map */
  264. static struct MemoryWriteAddress writemem2[] =
  265. {
  266.     { 0x0000, 0x07ff, starwars_sout_w },
  267.     { 0x1000, 0x107f, MWA_RAM }, /* 6532 ram */
  268.     { 0x1080, 0x109f, starwars_m6532_w },
  269.     { 0x1800, 0x183f, quad_pokey_w },
  270.     { 0x2000, 0x27ff, MWA_RAM }, /* program RAM */
  271.     { 0x4000, 0xbfff, MWA_ROM }, /* sound rom */
  272.     { 0xc000, 0xffff, MWA_ROM }, /* sound rom again, for intvecs */
  273.     { -1 }  /* end of table */
  274. };
  275.  
  276. static struct MemoryReadAddress esb_readmem[] =
  277. {
  278.     { 0x0000, 0x2fff, MRA_RAM },   /* vector_ram */
  279.     { 0x3000, 0x3fff, MRA_ROM },        /* vector_rom */
  280.     { 0x4300, 0x431f, input_port_0_r }, /* Memory mapped input port 0 */
  281.     { 0x4320, 0x433f, starwars_input_bank_1_r }, /* Memory mapped input port 1 */
  282.     { 0x4340, 0x435f, input_port_2_r },    /* DIP switches bank 0 */
  283.     { 0x4360, 0x437f, input_port_3_r },    /* DIP switches bank 1 */
  284.     { 0x4380, 0x439f, starwars_control_r }, /* a-d control result */
  285.     { 0x4400, 0x4400, starwars_main_read_r },
  286.     { 0x4401, 0x4401, starwars_main_ready_flag_r },
  287.     { 0x4500, 0x45ff, MRA_RAM },        /* nov_ram */
  288.     { 0x4700, 0x4700, reh_r },
  289.     { 0x4701, 0x4701, rel_r },
  290.     { 0x4703, 0x4703, prng_r },            /* pseudo random number generator */
  291. /*    { 0x4800, 0x4fff, MRA_RAM }, */        /* cpu_ram */
  292. /*    { 0x5000, 0x5fff, MRA_RAM }, */        /* (math_ram_r) math_ram */
  293.     { 0x4800, 0x5fff, MRA_RAM },        /* CPU and Math RAM */
  294.     { 0x6000, 0x7fff, MRA_BANK1 },        /* banked ROM */
  295.     { 0x8000, 0x9fff, esb_slapstic_r },
  296.     { 0xa000, 0xffff, MRA_BANK2 },        /* banked ROM */
  297.     { -1 }    /* end of table */
  298. };
  299.  
  300. static struct MemoryWriteAddress esb_writemem[] =
  301. {
  302.     { 0x0000, 0x2fff, MWA_RAM, &vectorram, &vectorram_size }, /* vector_ram */
  303.     { 0x3000, 0x3fff, MWA_ROM },        /* vector_rom */
  304.     { 0x4400, 0x4400, starwars_main_wr_w },
  305.     { 0x4500, 0x45ff, MWA_RAM },        /* nov_ram */
  306.     { 0x4600, 0x461f, avgdvg_go_w },
  307.     { 0x4620, 0x463f, avgdvg_reset_w },
  308.     { 0x4640, 0x465f, MWA_NOP },        /* (wdclr) Watchdog clear */
  309.     { 0x4660, 0x467f, MWA_NOP },        /* irqclr: clear periodic interrupt */
  310.     { 0x4680, 0x4687, starwars_out_w },
  311.     { 0x46a0, 0x46bf, MWA_NOP },        /* nstore */
  312.     { 0x46c0, 0x46c2, starwars_control_w },    /* Selects which a-d control port (0-3) will be read */
  313.     { 0x46e0, 0x46e0, starwars_soundrst_w },
  314.     { 0x4700, 0x4707, swmathbx_w },
  315. /*    { 0x4800, 0x4fff, MWA_RAM }, */        /* cpu_ram */
  316. /*    { 0x5000, 0x5fff, MWA_RAM }, */        /* (math_ram_w) math_ram */
  317.     { 0x4800, 0x5fff, MWA_RAM },        /* CPU and Math RAM */
  318.     { 0x8000, 0x9fff, esb_slapstic_w, &slapstic_area },        /* slapstic write */
  319.     { 0x6000, 0xffff, MWA_ROM },        /* main_rom */
  320.  
  321.     /* Dummy entry to set up the slapstic */
  322.     { 0x14000, 0x1bfff, MWA_NOP, &slapstic_base },
  323.     { -1 }    /* end of table */
  324. };
  325.  
  326. INPUT_PORTS_START( starwars )
  327.     PORT_START    /* IN0 */
  328.     PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_COIN2 )
  329.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
  330.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  331.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_TILT )
  332.     PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
  333.     PORT_BIT ( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  334.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_BUTTON4 )
  335.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
  336.  
  337.     PORT_START    /* IN1 */
  338.     PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
  339.     PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
  340.     PORT_BITX( 0x04, IP_ACTIVE_LOW, IPT_SERVICE, "Diagnostic Step", KEYCODE_F1, IP_JOY_NONE )
  341.     PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
  342.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3 )
  343.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  344.     /* Bit 6 is MATH_RUN - see machine/starwars.c */
  345.     PORT_BIT ( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  346.     /* Bit 7 is VG_HALT - see machine/starwars.c */
  347.     PORT_BIT ( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  348.  
  349.     PORT_START    /* DSW0 */
  350.     PORT_DIPNAME(0x03, 0x00, "Starting Shields" )
  351.     PORT_DIPSETTING (  0x00, "6" )
  352.     PORT_DIPSETTING (  0x01, "7" )
  353.     PORT_DIPSETTING (  0x02, "8" )
  354.     PORT_DIPSETTING (  0x03, "9" )
  355.     PORT_DIPNAME(0x0c, 0x00, DEF_STR( Difficulty ) )
  356.     PORT_DIPSETTING (  0x00, "Easy" )
  357.     PORT_DIPSETTING (  0x04, "Moderate" )
  358.     PORT_DIPSETTING (  0x08, "Hard" )
  359.     PORT_DIPSETTING (  0x0c, "Hardest" )
  360.     PORT_DIPNAME(0x30, 0x00, "Bonus Shields" )
  361.     PORT_DIPSETTING (  0x00, "0" )
  362.     PORT_DIPSETTING (  0x10, "1" )
  363.     PORT_DIPSETTING (  0x20, "2" )
  364.     PORT_DIPSETTING (  0x30, "3" )
  365.     PORT_DIPNAME(0x40, 0x00, DEF_STR( Demo_Sounds ) )
  366.     PORT_DIPSETTING (  0x40, DEF_STR( Off ) )
  367.     PORT_DIPSETTING (  0x00, DEF_STR( On ) )
  368.     PORT_DIPNAME(0x80, 0x80, "Freeze" )
  369.     PORT_DIPSETTING (  0x80, DEF_STR( Off ) )
  370.     PORT_DIPSETTING (  0x00, DEF_STR( On ) )
  371.  
  372.     PORT_START    /* DSW1 */
  373.     PORT_DIPNAME(0x03, 0x02, DEF_STR( Coinage ) )
  374.     PORT_DIPSETTING (  0x03, DEF_STR( 2C_1C ) )
  375.     PORT_DIPSETTING (  0x02, DEF_STR( 1C_1C ) )
  376.     PORT_DIPSETTING (  0x01, DEF_STR( 1C_2C ) )
  377.     PORT_DIPSETTING (  0x00, DEF_STR( Free_Play ) )
  378.     PORT_DIPNAME(0x0c, 0x00, DEF_STR( Coin_B ) )
  379.     PORT_DIPSETTING (  0x00, "*1" )
  380.     PORT_DIPSETTING (  0x04, "*4" )
  381.     PORT_DIPSETTING (  0x08, "*5" )
  382.     PORT_DIPSETTING (  0x0c, "*6" )
  383.     PORT_DIPNAME(0x10, 0x00, DEF_STR( Coin_A ) )
  384.     PORT_DIPSETTING (  0x00, "*1" )
  385.     PORT_DIPSETTING (  0x10, "*2" )
  386.     PORT_DIPNAME(0xe0, 0x00, "Bonus Coinage" )
  387.     PORT_DIPSETTING (  0x20, "2 gives 1" )
  388.     PORT_DIPSETTING (  0x60, "4 gives 2" )
  389.     PORT_DIPSETTING (  0xa0, "3 gives 1" )
  390.     PORT_DIPSETTING (  0x40, "4 gives 1" )
  391.     PORT_DIPSETTING (  0x80, "5 gives 1" )
  392.     PORT_DIPSETTING (  0x00, "None" )
  393. /* 0xc0 and 0xe0 None */
  394.  
  395.     PORT_START    /* IN4 */
  396.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_Y, 70, 30, 0, 255 )
  397.  
  398.     PORT_START    /* IN5 */
  399.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_X, 50, 30, 0, 255 )
  400. INPUT_PORTS_END
  401.  
  402.  
  403. INPUT_PORTS_START( esb )
  404.     PORT_START    /* IN0 */
  405.     PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_COIN2 )
  406.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
  407.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
  408.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_TILT )
  409.     PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
  410.     PORT_BIT ( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
  411.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_BUTTON4 )
  412.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
  413.  
  414.     PORT_START    /* IN1 */
  415.     PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED )
  416.     PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
  417.     PORT_BITX( 0x04, IP_ACTIVE_LOW, IPT_SERVICE, "Diagnostic Step", KEYCODE_F1, IP_JOY_NONE )
  418.     PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
  419.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3 )
  420.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  421.     /* Bit 6 is MATH_RUN - see machine/starwars.c */
  422.     PORT_BIT ( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  423.     /* Bit 7 is VG_HALT - see machine/starwars.c */
  424.     PORT_BIT ( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  425.  
  426.     PORT_START    /* DSW0 */
  427.     PORT_DIPNAME(0x03, 0x03, "Starting Shields" )
  428.     PORT_DIPSETTING (  0x01, "2" )
  429.     PORT_DIPSETTING (  0x00, "3" )
  430.     PORT_DIPSETTING (  0x03, "4" )
  431.     PORT_DIPSETTING (  0x02, "5" )
  432.     PORT_DIPNAME(0x0c, 0x0c, DEF_STR( Difficulty ) )
  433.     PORT_DIPSETTING (  0x08, "Easy" )
  434.     PORT_DIPSETTING (  0x0c, "Moderate" )
  435.     PORT_DIPSETTING (  0x00, "Hard" )
  436.     PORT_DIPSETTING (  0x04, "Hardest" )
  437.     PORT_DIPNAME(0x30, 0x30, "Jedi-Letter Mode" )
  438.     PORT_DIPSETTING (  0x00, "Level Only" )
  439.     PORT_DIPSETTING (  0x10, "Level" )
  440.     PORT_DIPSETTING (  0x20, "Increment Only" )
  441.     PORT_DIPSETTING (  0x30, "Increment" )
  442.     PORT_DIPNAME(0x40, 0x40, DEF_STR( Demo_Sounds ) )
  443.     PORT_DIPSETTING (  0x00, DEF_STR( Off ) )
  444.     PORT_DIPSETTING (  0x40, DEF_STR( On ) )
  445.     PORT_DIPNAME(0x80, 0x80, "Freeze" )
  446.     PORT_DIPSETTING (  0x80, DEF_STR( Off ) )
  447.     PORT_DIPSETTING (  0x00, DEF_STR( On ) )
  448.  
  449.     PORT_START    /* DSW1 */
  450.     PORT_DIPNAME(0x03, 0x02, DEF_STR( Coinage ) )
  451.     PORT_DIPSETTING (  0x03, DEF_STR( 2C_1C ) )
  452.     PORT_DIPSETTING (  0x02, DEF_STR( 1C_1C ) )
  453.     PORT_DIPSETTING (  0x01, DEF_STR( 1C_2C ) )
  454.     PORT_DIPSETTING (  0x00, DEF_STR( Free_Play ) )
  455.     PORT_DIPNAME(0x0c, 0x00, DEF_STR( Coin_B ) )
  456.     PORT_DIPSETTING (  0x00, "*1" )
  457.     PORT_DIPSETTING (  0x04, "*4" )
  458.     PORT_DIPSETTING (  0x08, "*5" )
  459.     PORT_DIPSETTING (  0x0c, "*6" )
  460.     PORT_DIPNAME(0x10, 0x00, DEF_STR( Coin_A ) )
  461.     PORT_DIPSETTING (  0x00, "*1" )
  462.     PORT_DIPSETTING (  0x10, "*2" )
  463.     PORT_DIPNAME(0xe0, 0xe0, "Bonus Coinage" )
  464.     PORT_DIPSETTING (  0x20, "2 gives 1" )
  465.     PORT_DIPSETTING (  0x60, "4 gives 2" )
  466.     PORT_DIPSETTING (  0xa0, "3 gives 1" )
  467.     PORT_DIPSETTING (  0x40, "4 gives 1" )
  468.     PORT_DIPSETTING (  0x80, "5 gives 1" )
  469.     PORT_DIPSETTING (  0xe0, "None" )
  470. /* 0xc0 and 0x00 None */
  471.  
  472.     PORT_START    /* IN4 */
  473.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_Y, 70, 30, 0, 255 )
  474.  
  475.     PORT_START    /* IN5 */
  476.     PORT_ANALOG( 0xff, 0x80, IPT_AD_STICK_X, 50, 30, 0, 255 )
  477. INPUT_PORTS_END
  478.  
  479.  
  480.  
  481. static struct POKEYinterface pokey_interface =
  482. {
  483.     4,            /* 4 chips */
  484.     1500000,    /* 1.5 MHz? */
  485.     { 20, 20, 20, 20 },    /* volume */
  486.     /* The 8 pot handlers */
  487.     { 0, 0, 0, 0 },
  488.     { 0, 0, 0, 0 },
  489.     { 0, 0, 0, 0 },
  490.     { 0, 0, 0, 0 },
  491.     { 0, 0, 0, 0 },
  492.     { 0, 0, 0, 0 },
  493.     { 0, 0, 0, 0 },
  494.     { 0, 0, 0, 0 },
  495.     /* The allpot handler */
  496.     { 0, 0, 0, 0 },
  497. };
  498.  
  499. static struct TMS5220interface tms5220_interface =
  500. {
  501.     640000,     /* clock speed (80*samplerate) */
  502.     50,         /* volume */
  503.     0           /* IRQ handler */
  504. };
  505.  
  506.  
  507.  
  508. static struct MachineDriver machine_driver_starwars =
  509. {
  510.     /* basic machine hardware */
  511.     {
  512.         /* Main CPU */
  513.         {
  514.             CPU_M6809,
  515.             1500000,                    /* 1.5 Mhz CPU clock (Don't know what speed it should be) */
  516.             readmem,writemem,0,0,
  517.             interrupt,6 /* 183Hz ? */
  518.             /* Increasing number of interrupts per frame speeds game up */
  519.         },
  520.         /* Sound CPU */
  521.         {
  522.             CPU_M6809 | CPU_AUDIO_CPU,
  523.             1500000,                    /* 1.5 Mhz CPU clock (Don't know what speed it should be) */
  524.             readmem2,writemem2,0,0,
  525.             0, 0,
  526.             0, 0    /* no regular interrupts, see sndhrdw/starwars.c */
  527.         }
  528.  
  529.     },
  530.     30, 0,    /* frames per second, vblank duration (vector game, so no vblank) */
  531.     1,        /* 1 CPU slice per frame. */
  532.     init_swmathbox,  /* Name of initialisation handler */
  533.  
  534.     /* video hardware */
  535.     400, 300, { 0, 250, 0, 280 },
  536.     0,
  537.     256,0, /* Number of colours, length of colour lookup table */
  538.     avg_init_palette_swars,
  539.  
  540.     VIDEO_TYPE_VECTOR,
  541.     0,                            /* Handler to initialise video handware */
  542.     avg_start_starwars,            /* Start video hardware */
  543.     avg_stop,                    /* Stop video hardware */
  544.     vector_vh_screenrefresh,    /* Do a screen refresh */
  545.  
  546.     /* sound hardware */
  547.     0,0,0,0,
  548.     {
  549.         {
  550.             SOUND_POKEY,
  551.             &pokey_interface
  552.         },
  553.         {
  554.             SOUND_TMS5220,
  555.             &tms5220_interface
  556.         }
  557.     },
  558.  
  559.     nvram_handler
  560. };
  561.  
  562. static struct MachineDriver machine_driver_esb =
  563. {
  564.     /* basic machine hardware */
  565.     {
  566.         /* Main CPU */
  567.         {
  568.             CPU_M6809,
  569.             1500000,                    /* 1.5 Mhz CPU clock (Don't know what speed it should be) */
  570.             esb_readmem, esb_writemem,0,0,
  571.             interrupt,6 /* 183Hz ? */
  572.             /* Increasing number of interrupts per frame speeds game up */
  573.         },
  574.         /* Sound CPU */
  575.         {
  576.             CPU_M6809 | CPU_AUDIO_CPU,
  577.             1500000,                    /* 1.5 Mhz CPU clock (Don't know what speed it should be) */
  578.             readmem2,writemem2,0,0,
  579.             0, 0,
  580.             0, 0    /* no regular interrupts, see sndhrdw/starwars.c */
  581.         }
  582.  
  583.     },
  584.     30, 0,    /* frames per second, vblank duration (vector game, so no vblank) */
  585.     1,        /* 1 CPU slice per frame. */
  586.     esb_init_machine,  /* Name of initialization handler */
  587.  
  588.     /* video hardware */
  589.     400, 300, { 0, 250, 0, 280 },
  590.     0,
  591.     256,0, /* Number of colours, length of colour lookup table */
  592.     avg_init_palette_swars,
  593.  
  594.     VIDEO_TYPE_VECTOR,
  595.     0,                            /* Handler to initialise video handware */
  596.     avg_start_starwars,            /* Start video hardware */
  597.     avg_stop,                    /* Stop video hardware */
  598.     vector_vh_screenrefresh,    /* Do a screen refresh */
  599.  
  600.     /* sound hardware */
  601.     0,0,0,0,
  602.     {
  603.         {
  604.             SOUND_POKEY,
  605.             &pokey_interface
  606.         },
  607.         {
  608.             SOUND_TMS5220,
  609.             &tms5220_interface
  610.         }
  611.     }
  612. };
  613.  
  614.  
  615.  
  616. /***************************************************************************
  617.  
  618.   Game driver
  619.  
  620. ***************************************************************************/
  621.  
  622. ROM_START( starwar1 )
  623.     ROM_REGION( 0x12000, REGION_CPU1 )     /* 2 64k ROM spaces */
  624.     ROM_LOAD( "136021.105",   0x3000, 0x1000, 0x538e7d2f ) /* 3000-3fff is 4k vector rom */
  625.     ROM_LOAD( "136021.114",   0x6000, 0x2000, 0xe75ff867 )   /* ROM 0 bank pages 0 and 1 */
  626.     ROM_CONTINUE(            0x10000, 0x2000 )
  627.     ROM_LOAD( "136021.102",   0x8000, 0x2000, 0xf725e344 ) /*  8k ROM 1 bank */
  628.     ROM_LOAD( "136021.203",   0xa000, 0x2000, 0xf6da0a00 ) /*  8k ROM 2 bank */
  629.     ROM_LOAD( "136021.104",   0xc000, 0x2000, 0x7e406703 ) /*  8k ROM 3 bank */
  630.     ROM_LOAD( "136021.206",   0xe000, 0x2000, 0xc7e51237 ) /*  8k ROM 4 bank */
  631.  
  632.     /* Load the Mathbox PROM's temporarily into the Vector RAM area */
  633.     /* During initialisation they will be converted into useable form */
  634.     /* and stored elsewhere. */
  635.     ROM_LOAD( "136021.110",   0x0000, 0x0400, 0x01061762 ) /* PROM 0 */
  636.     ROM_LOAD( "136021.111",   0x0400, 0x0400, 0x2e619b70 ) /* PROM 1 */
  637.     ROM_LOAD( "136021.112",   0x0800, 0x0400, 0x6cfa3544 ) /* PROM 2 */
  638.     ROM_LOAD( "136021.113",   0x0c00, 0x0400, 0x03f6acb2 ) /* PROM 3 */
  639.  
  640.     /* Sound ROMS */
  641.     ROM_REGION( 0x10000, REGION_CPU2 )     /* Really only 32k, but it looks like 64K */
  642.     ROM_LOAD( "136021.107",   0x4000, 0x2000, 0xdbf3aea2 ) /* Sound ROM 0 */
  643.     ROM_RELOAD(               0xc000, 0x2000 ) /* Copied again for */
  644.     ROM_LOAD( "136021.208",   0x6000, 0x2000, 0xe38070a8 ) /* Sound ROM 0 */
  645.     ROM_RELOAD(               0xe000, 0x2000 ) /* proper int vecs */
  646. ROM_END
  647.  
  648. ROM_START( starwars )
  649.     ROM_REGION( 0x12000, REGION_CPU1 )     /* 2 64k ROM spaces */
  650.     ROM_LOAD( "136021.105",   0x3000, 0x1000, 0x538e7d2f ) /* 3000-3fff is 4k vector rom */
  651.     ROM_LOAD( "136021.214",   0x6000, 0x2000, 0x04f1876e )   /* ROM 0 bank pages 0 and 1 */
  652.     ROM_CONTINUE(            0x10000, 0x2000 )
  653.     ROM_LOAD( "136021.102",   0x8000, 0x2000, 0xf725e344 ) /*  8k ROM 1 bank */
  654.     ROM_LOAD( "136021.203",   0xa000, 0x2000, 0xf6da0a00 ) /*  8k ROM 2 bank */
  655.     ROM_LOAD( "136021.104",   0xc000, 0x2000, 0x7e406703 ) /*  8k ROM 3 bank */
  656.     ROM_LOAD( "136021.206",   0xe000, 0x2000, 0xc7e51237 ) /*  8k ROM 4 bank */
  657.  
  658.     /* Load the Mathbox PROM's temporarily into the Vector RAM area */
  659.     /* During initialisation they will be converted into useable form */
  660.     /* and stored elsewhere. */
  661.     ROM_LOAD( "136021.110",   0x0000, 0x0400, 0x01061762 ) /* PROM 0 */
  662.     ROM_LOAD( "136021.111",   0x0400, 0x0400, 0x2e619b70 ) /* PROM 1 */
  663.     ROM_LOAD( "136021.112",   0x0800, 0x0400, 0x6cfa3544 ) /* PROM 2 */
  664.     ROM_LOAD( "136021.113",   0x0c00, 0x0400, 0x03f6acb2 ) /* PROM 3 */
  665.  
  666.     /* Sound ROMS */
  667.     ROM_REGION( 0x10000, REGION_CPU2 )     /* Really only 32k, but it looks like 64K */
  668.     ROM_LOAD( "136021.107",   0x4000, 0x2000, 0xdbf3aea2 ) /* Sound ROM 0 */
  669.     ROM_RELOAD(               0xc000, 0x2000 ) /* Copied again for */
  670.     ROM_LOAD( "136021.208",   0x6000, 0x2000, 0xe38070a8 ) /* Sound ROM 0 */
  671.     ROM_RELOAD(               0xe000, 0x2000 ) /* proper int vecs */
  672. ROM_END
  673.  
  674. ROM_START( esb )
  675.     ROM_REGION( 0x22000, REGION_CPU1 )     /* 64k for code and a buttload for the banked ROMs */
  676.     ROM_LOAD( "136031.111",   0x03000, 0x1000, 0xb1f9bd12 )    /* 3000-3fff is 4k vector rom */
  677.     ROM_LOAD( "136031.101",   0x06000, 0x2000, 0xef1e3ae5 )
  678.     ROM_CONTINUE(             0x10000, 0x2000 )
  679.     /* $8000 - $9fff : slapstic page */
  680.     ROM_LOAD( "136031.102",   0x0a000, 0x2000, 0x62ce5c12 )
  681.     ROM_CONTINUE(             0x1c000, 0x2000 )
  682.     ROM_LOAD( "136031.203",   0x0c000, 0x2000, 0x27b0889b )
  683.     ROM_CONTINUE(             0x1e000, 0x2000 )
  684.     ROM_LOAD( "136031.104",   0x0e000, 0x2000, 0xfd5c725e )
  685.     ROM_CONTINUE(             0x20000, 0x2000 )
  686.  
  687.     ROM_LOAD( "136031.105",   0x14000, 0x4000, 0xea9e4dce ) /* slapstic 0, 1 */
  688.     ROM_LOAD( "136031.106",   0x18000, 0x4000, 0x76d07f59 ) /* slapstic 2, 3 */
  689.  
  690.     /* Load the Mathbox PROM's temporarily into the Vector RAM area */
  691.     /* During initialisation they will be converted into useable form */
  692.     /* and stored elsewhere. These are 4-bit PROMs; the high nibble is ignored. */
  693.     ROM_LOAD( "136031.110",   0x0000, 0x0400, 0xb8d0f69d ) /* PROM 0 */
  694.     ROM_LOAD( "136031.109",   0x0400, 0x0400, 0x6a2a4d98 ) /* PROM 1 */
  695.     ROM_LOAD( "136031.108",   0x0800, 0x0400, 0x6a76138f ) /* PROM 2 */
  696.     ROM_LOAD( "136031.107",   0x0c00, 0x0400, 0xafbf6e01 ) /* PROM 3 */
  697.  
  698.     /* Sound ROMS */
  699.     ROM_REGION( 0x10000, REGION_CPU2 )
  700.     ROM_LOAD( "136031.113",   0x4000, 0x2000, 0x24ae3815 ) /* Sound ROM 0 */
  701.     ROM_CONTINUE(             0xc000, 0x2000 ) /* Copied again for */
  702.     ROM_LOAD( "136031.112",   0x6000, 0x2000, 0xca72d341 ) /* Sound ROM 1 */
  703.     ROM_CONTINUE(             0xe000, 0x2000 ) /* proper int vecs */
  704. ROM_END
  705.  
  706.  
  707.  
  708. GAME( 1983, starwars, 0,        starwars, starwars, starwars, ROT0, "Atari", "Star Wars (rev 2)" )
  709. GAME( 1983, starwar1, starwars, starwars, starwars, starwars, ROT0, "Atari", "Star Wars (rev 1)" )
  710. GAME( 1985, esb,      0,        esb,      esb,      starwars, ROT0, "Atari Games", "The Empire Strikes Back" )
  711.